//第一层
var express = require('express');
var router = express.Router();
const multiparty=require("multiparty");

const {add2,get2,delete2,getOne2,updataOne2} = require('../server/articalServer')

//图片上传
router.post('/addimg', async function (req, res, next){
    const form =new multiparty.Form();
   form.encoding="utf-8";
   form.uploadDir="./public/files";
   form.parse(req,function(err,fileds,files){   
       res.send(files)
    })
  
})

//新增
router.post('/add',async function(req,res,next){
    res.send(await add2(req.body))
})

//获取
router.get('/get',async function(req,res,next){
    res.send(await get2(req.query))
})

//删除
router.delete('/delete',async function(req,res,next){
    res.send(await delete2(req.body))
})

//获取修改数据
router.get('/getOne',async function(req,res,next){
    res.send(await getOne2(req.query))
})

//修改
router.post('/updataOne',async function(req,res,next){
    res.send(await updataOne2(req.body))
})


module.exports = router;